# -*- coding: UTF-8 -*-
# Author: Damon(wuud1)
# CreateDate:
# Message:

import requests
import sys
# 解决编码问题
reload(sys)
sys.setdefaultencoding('utf-8')

url = 'https://www.dwp.bmw-brilliance.cn/sap(bD16aCZjPTEwMA==)/bc/bsp/bmw/gis_tp_par_dev/spp05_stock_check.htm'
cookies = {
    'sap-contextid': "SID%3aANON%3apcqpdi33_CQP_33%3aal--bsHUsURzw8XTw8h3JNmIJuTnfMhzXhk3j2q--NEW",
    "sap-appcontext": "c2FwLXNlc3Npb25pZD1TSUQlM2FBTk9OJTNhcGNxcGRpMzNfQ1FQXzMzJTNhYWwtLUVCenVJZldDVnU2MW1CNkpTaEVrVUQzc2ZNaFlDaGxiV05wTy1BVFQ%3d",
    "SelectedMaterials": "",
    "Order_Selected_materials": "",
    "sap-usercontext": "sap-client=100",
    "BIGipServercqpcn.bmwbrill.cn_pool_8443": "3528863392.64288.0000",
    "MYSAPSSO2": "AjQxMDMBABg0ADAANAAyADkAUABBAFIAIAAgACAAIAACAAYxADAAMAADABBDAFEAUAAgACAAIAAgACAABAAYMgAwADEAOAAwADcAMgA2ADAAMgA1ADEABQAEAAAACAYAAlgACQACMQD%2fAVYwggFSBgkqhkiG9w0BBwKgggFDMIIBPwIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHjCCARoCAQEwbzBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTETMBEGA1UECxMKU0FQIFdlYiBBUzEUMBIGA1UECxMLSTAwMjA0NzQyNjExDDAKBgNVBAMTA0NRUAIHIBUJAglTWTAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMTgwNzI2MDI1MTM3WjAjBgkqhkiG9w0BCQQxFgQUAWscGja36SWqroDFcHJ%21h%2fhDeLgwCQYHKoZIzjgEAwQvMC0CFAjCrM3Sx2D9wvczUSbSqkkZ%21eRSAhUAoLDaaa4v642bJ3CUL0fcAgzPY3Y%3d",
    "lf_actionspage": "spp05_order_create.htm%3foninputprocessing(update)",
    "ordtype_create": "",
    "date_create": "",
    "po_create": "",
    "sppbasket": "",
    "sap-ssolist": "O3I9cGNxcGRpMzNfQ1FQXzMzXzEwMF81NkU5MEFFNURDN0JENkU4Qjc3NzM4NDhBM0E4NUY0NzE0RTRBRjQz",
    "SAP_SESSIONID_CQP_100": "X80qxBFSqjwRakGApOBrq2CEWgORPxHoo6wAFj4uVso%3d",
}
headers = {
    "Host": "www.dwp.bmw-brilliance.cn",
    "Authorization": "Basic NDA0MjlwYXI6MXEydzNlNHI=",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
    "Referer": "https://www.dwp.bmw-brilliance.cn/sap(bD16aCZjPTEwMA==)/bc/bsp/bmw/gis_tp_par_dev/SPP05_ORDER_CREATE_FRAME.htm",
}

res1 = requests.get(url=url, headers=headers, cookies=cookies, verify=False, timeout=30, allow_redirects=False)

with open('./demo1.html', 'w') as f:
    f.write(res1.content.decode("utf8"))

headers = res1.headers
cookies = res1.cookies.get_dict()
print headers
print cookies